<template>
    <div class="comment">
        <div class="avatar">
            <img v-lazy="$utils.getImgUrl(comment.user.avatarUrl, 80)" />
        </div>
        <div class="content" :class="{ border }">
            <div class="comment-text">
                <span class="username">{{ comment.user.nickname }}:</span>
                <span class="text">{{ comment.content}}</span>
            </div>
            <div class="replied" v-if="comment.beReplied.length">
                <p class="comment-text">
                    <span class="username">{{ comment.beReplied[0].user.nickname }}:</span>
                    <span class="text">{{ comment.beReplied[0].content }}</span>
                </p>
            </div>
            <div class="bottom">
                <span class="date">{{ $utils.formatDate(comment.time) }}</span>
                <div class="actions">
                    <Icon :size="12" type="good" />
                    {{ comment.likedCount }}
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: ["comment", "border"],
}
</script>

<style lang="scss" scoped>
.comment {
    display: flex;
    padding-top: 20px;

    .avatar {
        @include img-wrap(40px);
        margin-right: 12px;

        img {
            border-radius: 50%;
        }
    }

    .content {
        padding-bottom: 20px;
        font-size: $font-size-sm;
        width: 100%;

        &.border {
            border-bottom: 1px solid var(--border);
        }

        .replied {
            padding: 8px;
            margin-top: 8px;
            background: var(--song-shallow-grey-bg);
            border-radius: 4px;
        }

        .comment-text {
            .username {
                // display: inline-block;
                margin-right: 4px;
                color: $blue;
            }

            .text {
                line-height: 1.5;
            }
        }

        .bottom {
        display: flex;
        justify-content: space-between;
        margin-top: 8px;

        .date {
            color: var(--font-color-grey-shallow);
        }

        .actions {
            color: var(--font-color-grey-shallow);
        }
    }
    }
}
</style>
